<template>
<el-dialog class="project-assignment" :close-on-press-escape="false" :append-to-body="true" :title="giveData.title" :visible.sync="giveData.show" width="470px" :close-on-click-modal="false">
    <el-form ref="form" :model="giveData" :rules="rules">
        <el-form-item class="check-assignment">您即将永久转让自己的项目，以及与您的项目相关联的所有数据。<br/>确认转让项目后，无法撤销或恢复。</el-form-item>
        <el-form-item label="用户名" prop="value">
            <el-select v-model="giveData.value" filterable clearable placeholder="请选择用户名">
                <el-option v-for="(item, i) in giveData.list" :key="i" :label="item.username" :value="item.username"></el-option>
            </el-select>
        </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="giveData.show=false">取 消</el-button>
      <el-button type="primary" style="background:#FFA800;border-color:#FFA800" v-preventReClick="2000" @click="handleSave">转 让</el-button>
    </span>
</el-dialog>
</template>

<script>
export default {
    name: 'GiveDialog',
    props: {
        giveData: {
            type: Object,
            required: true
        }
    },
    data () {
        return {
            rules: {
                value: [
                    {
                        required: true,
                        message: '请选择用户名',
                        trigger: 'changge'
                    }
                ]
            }
        }
    },
    methods: {
        handleSave (flag) {
            this.$refs['form'].validate((valid) => {
                if (valid) {
                    this.$emit('save')
                } else {
                    return false
                }
            })
        }
    }
}
</script>
<style lang="less">
.project-assignment {
    .el-dialog__close {
        font-size: 20px;
        font-weight: bold;
        color: #515151;
    }
    .el-form {
        display: flex;
        flex-direction: column;
        .el-form-item {
            margin-bottom: 0;
        }
    }
    .el-dialog__header {
        padding-left: 24px;
    }
    .el-dialog__body {
        padding: 24px;
        height: 230px;
    }
    .el-input {
        width: 310px !important;
    }
    .check-assignment {
        display: inline-block;
        margin-bottom: 24px !important;
        .el-form-item__content {
            line-height: 24px;
        }
        // margin: 0 5px;
    }
}
</style>
